package org.mathcloud.math.core.scilab.quantity;

import org.mathcloud.math.core.common.operator.QuantityObjectOperation;
import org.mathcloud.math.core.common.quantity.QuantityObject;
import org.mathcloud.math.core.common.signature.QuantityObjectSignature;
import org.mathcloud.math.core.scilab.manager.ScilabSupervisor;
import org.scilab.modules.javasci.JavasciException;
import org.scilab.modules.javasci.Scilab;
import org.scilab.modules.types.ScilabDouble;

public class ScilabQuantityObject implements QuantityObject
{
	public ScilabQuantityObject()
	{
		sciEngine = ScilabSupervisor.getScilabEngine();
		sciVarName = "scilab_qnty_"+ScilabSupervisor.getVarId();
	}
	
	@Override
	public QuantityObjectOperation getOperation()
	{
		return null;
	}

	@Override
	public QuantityObjectSignature getSignature()
	{
		return signature;
	}
	
	public Scilab getScilabEngine()
	{
		return sciEngine;
	}
	
	public ScilabDouble getScilabObject()
	{
		return sciObject;
	}
	
	public void setScilabEngine(Scilab engine)
	{
		sciEngine = engine;
	}
	
	public void setScilabObject(ScilabDouble sciObject)
	{
		this.sciObject = sciObject;
		try
		{
			sciEngine.put(sciVarName, this.sciObject);
		} catch (JavasciException e)
		{
			e.printStackTrace();
		}
	}
	
	public String getVarName()
	{
		return sciVarName;
	}	
	
	protected ScilabDouble sciObject;
	protected Scilab sciEngine;
	protected String sciVarName;
	protected QuantityObjectSignature signature;
}
